package com.ruoyi.dangerControl.service.impl;

import java.util.List;

import com.ruoyi.dangerControl.domain.HdTrainDept;
import com.ruoyi.dangerControl.domain.SysDepart;
import com.ruoyi.dangerControl.dto.HdTrainDeptDto;
import com.ruoyi.dangerControl.mapper.HdTrainDeptMapper;
import com.ruoyi.dangerControl.vo.HdTrainVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.dangerControl.mapper.HdTrainScoreMapper;
import com.ruoyi.dangerControl.domain.HdTrainScore;
import com.ruoyi.dangerControl.service.IHdTrainScoreService;

/**
 * 隐患-培训管理-部门Service业务层处理
 *
 * @author lth
 * @date 2023-12-20
 */
@Service
public class HdTrainScoreServiceImpl implements IHdTrainScoreService
{
    @Autowired
    private HdTrainScoreMapper hdTrainScoreMapper;

    @Autowired
    private HdTrainDeptMapper hdTrainDeptMapper;

    /**
     * 查询隐患-培训管理-部门
     *
     * @param id 隐患-培训管理-部门主键
     * @return 隐患-培训管理-部门
     */
    @Override
    public HdTrainScore selectHdTrainScoreById(Long id)
    {
        return hdTrainScoreMapper.selectHdTrainScoreById(id);
    }

    /**
     * 查询隐患-培训管理-部门列表
     *
     * @param hdTrainScore 隐患-培训管理-部门
     * @return 隐患-培训管理-部门
     */
    @Override
    public List<HdTrainScore> selectHdTrainScoreList(HdTrainScore hdTrainScore)
    {
        return hdTrainScoreMapper.selectHdTrainScoreList(hdTrainScore);
    }

    /**
     * 新增隐患-培训管理-部门
     *
     * @param hdTrainScore 隐患-培训管理-部门
     * @return 结果
     */
    @Override
    public int insertHdTrainScore(HdTrainScore hdTrainScore)
    {
        return hdTrainScoreMapper.insertHdTrainScore(hdTrainScore);
    }

    /**
     * 修改隐患-培训管理-部门
     *
     * @param hdTrainScore 隐患-培训管理-部门
     * @return 结果
     */
    @Override
    public int updateHdTrainScore(HdTrainScore hdTrainScore)
    {
        return hdTrainScoreMapper.updateHdTrainScore(hdTrainScore);
    }

    /**
     * 批量删除隐患-培训管理-部门
     *
     * @param ids 需要删除的隐患-培训管理-部门主键
     * @return 结果
     */
    @Override
    public int deleteHdTrainScoreByIds(Long[] ids)
    {
        return hdTrainScoreMapper.deleteHdTrainScoreByIds(ids);
    }

    /**
     * 删除隐患-培训管理-部门信息
     *
     * @param id 隐患-培训管理-部门主键
     * @return 结果
     */
    @Override
    public int deleteHdTrainScoreById(Long id)
    {
        return hdTrainScoreMapper.deleteHdTrainScoreById(id);
    }

    /**     通过部门ID查询部门内人员列表
    * @Author lth
    * @Description //TODO
    * @Date 20:06 2023/12/20
    * @Param
    * @return
     **/
    @Override
    public HdTrainDeptDto getDepartPersonList(HdTrainVo vo) {
        Long trainId = vo.getId();
        HdTrainDept hdTrainDept = hdTrainDeptMapper.getListByTrainId(trainId);
        List<HdTrainScore> scoreList = hdTrainScoreMapper.getDepartPersonList(trainId);
        HdTrainDeptDto hdTrainDeptDto = new HdTrainDeptDto();
        hdTrainDeptDto.setTrainId(trainId);
        hdTrainDeptDto.setScoreList(scoreList);
        hdTrainDeptDto.setCode(hdTrainDept.getCode());
        hdTrainDeptDto.setName(hdTrainDept.getName());
        hdTrainDeptDto.setId(hdTrainDept.getId());
        return hdTrainDeptDto;
    }
}
